package com.example.auto_rental.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @Name: MyMetaObjectHandler
 * @Author: Jovan
 * @Date: 2024/9/12 16:54
 * @Description: 实现mybatis plus 自动填充功能
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
   @Override
    public void insertFill(MetaObject metaObject) {
       this.strictInsertFill(metaObject,"createTime",LocalDateTime::now, LocalDateTime.class);
       this.strictInsertFill(metaObject,"updateTime",LocalDateTime::now, LocalDateTime.class);
   }
   @Override
    public void updateFill(MetaObject metaObject) {
       this.strictUpdateFill(metaObject,"updateTime",LocalDateTime::now, LocalDateTime.class);
   }
}
